from sanic import Blueprint
from sanic.response import json
from biz_code.component.comm import public_utils

admin_login_blu = Blueprint(__name__)


@admin_login_blu.route("/admin_login", methods=["POST"])
async def admin_login(request):
    ret = {"code": 0, "msg": "请求成功"}

    try:

        # 参数校验
        public_utils.params_verify(request)

        # 管理员登录
        func = request.app.func_map.get("60550001")

        # 判断接口号处理方法是否存在
        if not func:
            raise Exception("func  not  fund")

        ret = await func(request)

    except Exception as error:
        print("error msg: ", error)
        ret["code"] = -1
        ret["msg"] = "请求错误"
    finally:
        return json(ret)
